package com.googlecode.kevinarpe.papaya.filesystem.compare;

/*
 * #%L
 * This file is part of Papaya.
 * %%
 * Copyright (C) 2013 - 2014 Kevin Connor ARPE (kevinarpe@gmail.com)
 * %%
 * Papaya is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GPL Classpath Exception:
 * This project is subject to the "Classpath" exception as provided in
 * the LICENSE file that accompanied this code.
 * 
 * Papaya is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Papaya.  If not, see <http://www.gnu.org/licenses/>.
 * #L%
 */

import com.googlecode.kevinarpe.papaya.compare.AbstractLexicographicalComparator;
import com.googlecode.kevinarpe.papaya.compare.CaseSensitive;
import com.googlecode.kevinarpe.papaya.compare.ComparatorUtils;
import org.testng.annotations.Test;

import java.io.File;

/**
 * @author Kevin Connor ARPE (kevinarpe@gmail.com)
 */
public abstract class AbstractFileLexicographicalComparatorTestBase
        <TComparator extends AbstractLexicographicalComparator<File, TComparator>>
extends AbstractFileComparatorTestBase<TComparator, String> {

    protected abstract TComparator newComparator(CaseSensitive caseSensitive);

    ////////////////////////////////////////////////////////////////////////////////////////////////
    // Helpers
    //

    @Override
    public int compareStrings(TComparator comparator, String left, String right) {
        int result = (comparator.isCaseSensitive() ?
            left.compareTo(right) : left.compareToIgnoreCase(right));
        result = ComparatorUtils.normalizeCompareResult(result);
        return result;
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////
    // AbstractFileLexicographicalComparatorTestBase.ctor()
    //

    @Test
    public void ctor_Pass2() {
        for (CaseSensitive cs : CaseSensitive.values()) {
            newComparator(cs);
        }
    }
}
